Skip to content

Conversation

@Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented Sep 27, 2024

Problem

We want to avoid fs-extra, and eventually move it to the banned import list. As a first step, we remove fs-extra with as much of our own fs.ts work, and fs when not possible.

This PR only works on non-testing code. This way we can ensure our tests are not compromised, and still show that our code exhibits the desired behavior.

Solution

Indirect Translations

Otherwise the translations are fairly direct.

Notes

As of 9/30 there is a tech debt test failing blocking potential merge. This test was pushed back to 10/30.


License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions
Copy link

This pull request modifies code in src/ but no tests were added/updated. Confirm whether tests should be added or ensure the PR description explains why tests are not required.

@Hweinstock
Copy link
Contributor Author

/retryBuilds

@Hweinstock Hweinstock marked this pull request as ready for review September 30, 2024 18:21
@Hweinstock Hweinstock requested review from a team as code owners September 30, 2024 18:21
config.eventPayloadFile === undefined
? undefined
: JSON.parse(await readFile(config.eventPayloadFile, { encoding: 'utf-8' }))
: JSON.parse(await fs.readFileAsString(config.eventPayloadFile))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

off-topic: we should rename this function :)

Suggested change
: JSON.parse(await fs.readFileAsString(config.eventPayloadFile))
: JSON.parse(await fs.readFileText(config.eventPayloadFile))

Copy link
Contributor Author

@Hweinstock Hweinstock Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, its not obvious that its auto-converting the file bytes to text. I'll track it, and can do this in a follow up. I think there's enough going on in this PR.

await fs.appendFile(sshConfigPath, section, { mode: 0o600 })
const parentsDir = path.dirname(sshConfigPath)
const grandParentsDir = path.dirname(parentsDir)
// TODO: replace w/ fs.chmod once stub is merged.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#5647 is ready to merge

fs.copySync(path.join(tempPath, 'usr', 'local', 'sessionmanagerplugin'), outDir, {
recursive: true,
})
await fs.copy(path.join(tempPath, 'usr', 'local', 'sessionmanagerplugin'), outDir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.copy needs a docstring, it's not obvious that it also supports folders.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracked as a followup, seems like there a few other methods that could use them as well in fs.

Copy link
Contributor

@justinmk3 justinmk3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Hweinstock Hweinstock requested a review from a team as a code owner October 1, 2024 13:22
@Hweinstock
Copy link
Contributor Author

@aws/dexp @aws/codewhisperer-team

@justinmk3 justinmk3 merged commit ee917c0 into aws:master Oct 2, 2024
9 of 10 checks passed
Hweinstock added a commit that referenced this pull request Oct 4, 2024
## Problem
In the recent refactor
(#5689), there is a
mismatch in args between our fs and fs-extra. Not caught until integ
tests were run.

## Solution
have default write file method ignores encoding since it uses utf8
anyway.

---

<!--- REMINDER: Ensure that your PR meets the guidelines in
CONTRIBUTING.md -->

License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
Hweinstock added a commit that referenced this pull request Oct 4, 2024
## Problem
Follow up from #5689,
focusing on the test files.

## Solution
Mostly direct translation, one implementation change from `writeJson` to
`Json.stringify` then `writeFile` in
`packages/core/src/test/awsService/cdk/detectCdkProjects.test.ts` line
120

---

<!--- REMINDER: Ensure that your PR meets the guidelines in
CONTRIBUTING.md -->

License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
Hweinstock added a commit that referenced this pull request Oct 7, 2024
…gs (#5713)

## Problem
Follow up from: #5689

## Solution
- rename 'readFileAsString' to 'readFileText' since this function
assumes a text file (utf-8) encoding.
- Add missing doc strings to copy and exist within fs wrapper. 

---

<!--- REMINDER: Ensure that your PR meets the guidelines in
CONTRIBUTING.md -->

License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.

---------

Co-authored-by: Justin M. Keyes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants